perm filename HALDEF.OLD[HAL,HE] blob
sn#118159 filedate 1974-09-05 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00005 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 .SBTTL standard definitions for HAL runtime routines
C00004 00003 .SBTTL useful macros and initialization of traps
C00006 00004 .SBTTL TTY output routines
C00010 00005 .SBTTL constants and variables
C00011 ENDMK
C⊗;
.SBTTL standard definitions for HAL runtime routines
; PROGRAM DEFINITIONS
ERRTRP=4 ;time out and error trap
IGLINS=10 ;illegal instruction
CLKTRP=104 ;clock trap
PS=177776 ;processor status word
KBIS=177560 ;keyboard input status
KBIR=177562 ;keyboard input register
KBOS=177564 ;keyboard output status
KBOR=177566 ;keyboard output register
CLKCNT=172544 ;clock counter
CLKSET=172542 ;clock set register
CLKS=172540 ;clock status
STRT11=500 ;starting address of program
IBUF=150 ;start of input buffer from 11
OBUF=160 ;start of output buffer to 11
HCOR=77776 ;highest useable word in core
;REGISTER DEFINITIONS
PC=%7 ;program counter
SP=%6 ;stack pointer
RF=%5 ;Display pointer
R4=%4 ;Saved across procedure calls
R3=%3 ;Saved across procedure calls
R2=%2 ;Saved across procedure calls
R1=%1 ;temp
R0=%0 ;temp
.SBTTL useful macros and initialization of traps
.MACRO OUTSTR B ; type string starting at B
MOV R0,-(SP) ;Stack R0 to save it.
MOV R1,-(SP) ;Stack r1 to save it.
MOV B,R0 ;Load up argument for TYPSTR
JSR PC,TYPSTR ; and call it.
MOV (SP)+,R1 ;Restore R1
MOV (SP)+,R0 ;Restore R0
.ENDM
.MACRO CRLF ; type CRLF
OUTSTR CRLFX
.ENDM
.MACRO NUMOCT B ; type octal number in word B
MOV R0,-(SP) ;Stack R0 to save it.
MOV R1,-(SP) ;Stack R1 to save it.
MOV B,R0 ;Load up argument for TYPOCT
JSR PC,TYPOCT ; and call it.
MOV (SP)+,R1 ;Restore R1
MOV (SP)+,R0 ;Resotre R0
.ENDM
.MACRO NUMDEC B ; type decimal number in word B
MOV R0,-(SP) ;Stack R0 to save it.
MOV R1,-(SP) ;Stack R1 to save it.
MOV B,R0 ;Load up argument for TYPDEC
JSR PC,TYPDEC ; and call it.
MOV (SP)+,R1 ;Restore R1
MOV (SP)+,R0 ;Resotre R0
.ENDM
.MACRO TTYIN B ; input a character into word (or reg.) B
TSTB KBIS ;Is TTY holding an input?
BEQ .-4 ;Yes. Busy wait.
MOV KBIR,B
BIC #200,B ;Clear #200 bit of input.
.ENDM
.=CLKTRP ;clock trap dispatch
CLKIN
340
.SBTTL TTY output routines
; Modified 5-sep-74 by RF. Originally written by KKP.
; Output a string, ending with a zero character. Pointer to start
; of string in R0. Called in "simple" style.
TYPSTR: MOV R0,R1 ;R1 ← LOC[STRING]
MOVB (R1)+,R0 ;R0 ← first byte of string
TSLOOP: JSR PC,TYPCHR ;Type this one character
MOVB (R1)+,R0 ;R0 ← Next byte of string
BNE TSLOOP ;If more to come, repeat.
RTS PC ;Done
; Routines to output numbers. Argument in R0.
TYPDEC: MOV 10.,RADIX ;To outpot in base 10.
BR typdig ;Go type it.
TYPOCT: MOV #8,RADIX ;To output in base 8.
BR TYPDIG ;Go type it.
TYPDIG: MOV R0,R1 ;Subroutine TYPDG2 needs argument in R1
TYPDG2: CLR R0 ;Clear upper half of dividend.
DIV (PC)+,R0 ;Divide argument in R0 by radix.
RADIX: 12 ;Starts out in decimal.
BEQ TYPOUT ;If quotient zero, then can print.
MOV R0,-(SP) ;Else stack quotient
JSR PC,TYPDG2 ;Recursive call.
MOV (SP)+,R0 ;Unstack last quotient
TYPOUT: ADD #'0,R0 ;Form TTY code for digit
TYPCHR: TSTB KBOS ;Is TTY available
BPL TYPCHR ;No. Busy wait for it.
MOVB R0,KBOR ;Yes. Output a byte to it.
CMP #12,R0 ;Check for code #332. I dont understand.
BNE TYPRET ;If not that code, then done.
CLR R0 ;Otherwise, output 3 nulls.
JSR PC,TYPCHR ;
JSR PC,TYPCHR ;
JSR PC,TYPCHR ;
TYPRET: RTS PC ;Return.
.SBTTL constants and variables
CRLFX:
.ASCIZ /
/
HALNAM:
.ASCIZ /HAL Runtime/
.EVEN